package com.medusa.aps.business.modules.plan.mp.entity;

import cn.hutool.core.annotation.Alias;
import com.alibaba.fastjson2.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.medusa.aps.business.model.BaseEntity;
import com.medusa.aps.business.model.enums.ManufacturingStrategy;
import com.medusa.aps.business.model.enums.ProductionType;
import com.medusa.aps.business.model.enums.SchedulingStatusEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 建议计划实体类
 *
 * @author yuxh
 * @since 2023-08-14 17:37:50
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class SuggestedPlan extends BaseEntity<SuggestedPlan> {
    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    @Schema(description = "主键id")
    private Integer id;
    /**
     * 订单id
     */
    @Schema(description = "订单id")
    private Integer orderId;
    /**
     * 订单号
     */
    @Schema(description = "订单号")
    @Alias("订单号")
    private String orderNumber;
    /**
     * 物料id
     */
    @Schema(description = "物料id")
    private Long materialId;
    /**
     * 物料编码
     */
    @Schema(description = "物料编码")
    @Alias("物料编码")
    private String materialCode;
    /**
     * 物料名称
     */
    @Schema(description = "物料名称")
    @Alias("物料名称")
    private String materialName;
    /**
     * 制造策略
     */
    @Schema(description = "制造策略")
    @Alias("制造策略")
    private ManufacturingStrategy manufacturingStrategy;
    /**
     * 生产类型
     */
    @Schema(description = "生产类型")
    @Alias("生产类型")
    private ProductionType productionType;
    /**
     * 需求数量
     */
    @Schema(description = "需求数量")
    @Alias("需求数量")
    private BigDecimal demandQuantity;
    /**
     * 订单交期
     */
    @Schema(description = "订单交期")
    @Alias("订单交期")
    private LocalDate orderDeliveryTime;
    /**
     * 需求时间
     */
    @Alias("需求时间")
    @Schema(description = "需求时间")
    private LocalDate demandTime;
    /**
     * 计划数量
     */
    @Alias("计划数量")
    @Schema(description = "计划数量")
    private BigDecimal plannedQuantity;
    /**
     * 计划开始时间
     */
    @Alias("计划开始时间")
    @Schema(description = "计划开始时间")
    private LocalDateTime planStartTime;
    /**
     * 计划结束时间
     */
    @Schema(description = "计划结束时间")
    @Alias("计划结束时间")
    private LocalDateTime planCompletionTime;
    /**
     * 实际库存
     */
    @Alias("实际库存")
    @Schema(description = "实际库存")
    private BigDecimal immediateInventory;
    /**
     * 占有库存
     */
    @Alias("物料占用量")
    @Schema(description = "物料占用量")
    private BigDecimal possessionInventory;
    /**
     * 创建人
     */
    @Schema(description = "创建人")
    @TableField(value = "creator", fill = FieldFill.INSERT)
    private String creator;

    /**
     * 排产状态
     */
    @Schema(description = "排产状态")
    @JSONField(serialize = false, deserialize = false)
//    @TableField(typeHandler = EnumOrdinalTypeHandler.class)
    private SchedulingStatusEnum schedulingStatus;
    /**
     * 层级
     */
    @TableField(value = "`level`")
    @JSONField(serialize = false, deserialize = false)
    private Integer level;
    /**
     * 父级物料编码
     */
    @JSONField(serialize = false, deserialize = false)
    private String materialParentCode;

    /**
     * 获取主键值
     *
     * @return 主键值
     */
    @Override
    public Serializable pkVal() {
        return this.id;
    }
}

